import { EventEmitter } from "./src";

const emitter = new EventEmitter();

// addListener
emitter.addListener('event', (arg1: any, arg2: any) => {
    console.log(`listener1: ${arg1} ${arg2}`);
});
emitter.addListener('event', (arg1: any, arg2: any) => {
    console.log(`listener2: ${arg1} ${arg2}`);
});

// emit
emitter.emit('event', 'foo', 'bar');

// removeListener
const listener1 = (arg1: any, arg2: any) => {
    console.log(`listener1: ${arg1} ${arg2}`);
};
emitter.addListener('event', listener1);
emitter.removeListener('event', listener1);

// removeAllListeners
emitter.removeAllListeners('event');

// setMaxListeners
emitter.maxListeners = 5;

// getMaxListeners
console.log(emitter.maxListeners);

// listeners
console.log(emitter.listeners('event'));

// rawListeners
console.log(emitter.rawListeners('event'));

// listenerCount
console.log(emitter.listenerCount('event'));

// prependListener
emitter.prependListener('event', (arg1: any, arg2: any) => {
    console.log(`listener1: ${arg1} ${arg2}`);
});

// prependOnceListener
emitter.prependOnceListener('event', (arg1: any, arg2: any) => {
    console.log(`listener1: ${arg1} ${arg2}`);
});

// once
emitter.once('event', (arg1: any, arg2: any) => {
    console.log(`listener1: ${arg1} ${arg2}`);
});


